package gamePack;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class KeyManager implements KeyListener {

	private Game game;

	public KeyManager(Game game) {
		this.game = game;
	}

	public void keyPressed(KeyEvent e) {
		if (e.getKeyCode() == KeyEvent.VK_UP) {
			game.getPlayer().setUp(true);
		}
		if (e.getKeyCode() == KeyEvent.VK_DOWN) {
			game.getPlayer().setDn(true);
		}
		if (e.getKeyCode() == KeyEvent.VK_LEFT) {
			game.getPlayer().setLt(true);
		}
		if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
			game.getPlayer().setRt(true);
		}
		if (e.getKeyCode() == KeyEvent.VK_SPACE) {
			game.getPlayer().setDisparo(true);
		}
	}

	public void keyReleased(KeyEvent e) {
		if (e.getKeyCode() == KeyEvent.VK_UP) {
			game.getPlayer().setUp(false);
		}
		if (e.getKeyCode() == KeyEvent.VK_DOWN) {
			game.getPlayer().setDn(false);
		}
		if (e.getKeyCode() == KeyEvent.VK_LEFT) {
			game.getPlayer().setLt(false);
		}
		if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
			game.getPlayer().setRt(false);
		}
		if (e.getKeyCode() == KeyEvent.VK_SPACE) {
			game.getPlayer().setDisparo(false);
			game.getPlayer().setDisparando(false);
		}
	}

	public void keyTyped(KeyEvent e) {

	}

}
